package com.handheld.uhfdemo1;


import com.handheld.uhfdemo1.annotations.ExcelContent;
import com.handheld.uhfdemo1.annotations.ExcelContentCellFormat;
import com.handheld.uhfdemo1.annotations.ExcelSheet;
import com.handheld.uhfdemo1.annotations.ExcelTitleCellFormat;

import jxl.format.Alignment;
import jxl.format.Border;
import jxl.format.BorderLineStyle;
import jxl.format.Colour;
import jxl.format.UnderlineStyle;
import jxl.format.VerticalAlignment;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WriteException;

/**
 * 用户表，作为用户的导出Excel的中间格式化实体，所有字段都为 String
 */
@ExcelSheet(sheetName = "Sheet1")
public class ExcelDataBean {

	@ExcelContent(titleName = "EPC",index = 0)
	private String Epc;

	@ExcelContent(titleName = "监控点编码",index = 1)
	private String locationCode;
	@ExcelContent(titleName = "安装地址",index = 2)
	private String installLocation;
	@ExcelContent(titleName = "IP地址",index = 3)
	private String IpAddress;

	@ExcelContent(titleName = "国标ID",index = 4)
	private String GBID;

	@ExcelContent(titleName = "一机一档摄像机名称",index = 5)
	private String cameraName;

	@ExcelContent(titleName = "杆体编号",index = 6)
	private String RodNumber;

	@ExcelContent(titleName = "经度",index = 7)
	private String longitude;

	@ExcelContent(titleName = "纬度",index = 8)
	private String latitude ;


	@ExcelContent(titleName = "巡检内容",index = 9)
	private String Inspection;

	@ExcelContent(titleName = "是否故障",index = 10)
	private String error;

	@ExcelContent(titleName = "故障原因",index = 11)
	private String errorReason;

	@ExcelContent(titleName = "故障修复情况",index = 12)
	private String errorFixState;


	@ExcelContent(titleName = "巡查时间",index = 13)
	private String InspectionTime;

	@ExcelContent(titleName = "备注",index = 14)
	private String Memo;


	@ExcelTitleCellFormat(titleName = "EPC")
	private static WritableCellFormat getTitleFormat() {
		WritableCellFormat format = new WritableCellFormat();
		try {
			// 单元格格式
			// 背景颜色
			// format.setBackground(Colour.PINK);
			// 边框线
			format.setBorder(Border.BOTTOM, BorderLineStyle.THIN, Colour.RED);
			// 设置文字居中对齐方式;
			format.setAlignment(Alignment.CENTRE);
			// 设置垂直居中;
			format.setVerticalAlignment(VerticalAlignment.CENTRE);
			// 设置自动换行
			format.setWrap(false);

			// 字体格式
			WritableFont font = new WritableFont(WritableFont.ARIAL);
			// 字体颜色
			font.setColour(Colour.BLUE2);
			// 字体加粗
			font.setBoldStyle(WritableFont.BOLD);
			// 字体加下划线
			font.setUnderlineStyle(UnderlineStyle.SINGLE);
			// 字体大小
			font.setPointSize(20);
			format.setFont(font);

		} catch (WriteException e) {
			e.printStackTrace();
		}
		return format;
	}

	private static int f1flag = 0;
	private static int f2flag = 0;
	private static int f3flag = 0;
	private static int f4flag = 0;
	private static int f5flag = 0;
	private static int f6flag = 0;

	@ExcelContentCellFormat(titleName = "姓名")
	private WritableCellFormat f1() {
		WritableCellFormat format = null;
		try {
			format = new WritableCellFormat();
			if ((f1flag & 1) != 0) {
				format.setBackground(Colour.GRAY_25);
			}

		/*	if (EPC.contains("4")) {
				format.setBackground(Colour.RED);
			}
*/
			f1flag++;
		} catch (WriteException e) {
			e.printStackTrace();
		}
		return format;
	}
/*

	@ExcelContentCellFormat(titleName = "监控点编码")
	private WritableCellFormat f2() {
		WritableCellFormat format = null;
		try {
			format = new WritableCellFormat();
			if ((f2flag & 1) != 0) {
				format.setBackground(Colour.GRAY_25);
			}
			f2flag++;
		} catch (WriteException e) {
			e.printStackTrace();
		}
		return format;
	}

	@ExcelContentCellFormat(titleName = "地址")
	private WritableCellFormat f3() {
		WritableCellFormat format = null;
		try {
			format = new WritableCellFormat();
			if ((f3flag & 1) != 0) {
				format.setBackground(Colour.GRAY_25);
			}
			f3flag++;
		} catch (WriteException e) {
			e.printStackTrace();
		}
		return format;
	}

	@ExcelContentCellFormat(titleName = "电话")
	private WritableCellFormat f4() {
		WritableCellFormat format = null;
		try {
			format = new WritableCellFormat();
			if ((f4flag & 1) != 0) {
				format.setBackground(Colour.GRAY_25);
			}
			f4flag++;
		} catch (WriteException e) {
			e.printStackTrace();
		}
		return format;
	}

	@ExcelContentCellFormat(titleName = "其他")
	private WritableCellFormat f5() {
		WritableCellFormat format = null;
		try {
			format = new WritableCellFormat();
			if ((f5flag & 1) != 0) {
				format.setBackground(Colour.GRAY_25);
			}
			f5flag++;
		} catch (WriteException e) {
			e.printStackTrace();
		}
		return format;
	}

	@ExcelContentCellFormat(titleName = "备注")
	private WritableCellFormat f6() {
		WritableCellFormat format = null;
		try {
			format = new WritableCellFormat();
			if ((f6flag & 1) != 0) {
				format.setBackground(Colour.GRAY_25);
			}
			f6flag++;
		} catch (WriteException e) {
			e.printStackTrace();
		}
		return format;
	}
*/

	public ExcelDataBean() {

	}

	public String getEpc() {
		return Epc;
	}

	public void setEpc(String epc) {
		Epc = epc;
	}

	public String getInstallLocation() {
		return installLocation;
	}

	public void setInstallLocation(String installLocation) {
		this.installLocation = installLocation;
	}

	public String getIpAddress() {
		return IpAddress;
	}

	public void setIpAddress(String ipAddress) {
		IpAddress = ipAddress;
	}

	public String getGBID() {
		return GBID;
	}

	public void setGBID(String GBID) {
		this.GBID = GBID;
	}

	public String getCameraName() {
		return cameraName;
	}

	public void setCameraName(String cameraName) {
		this.cameraName = cameraName;
	}

	public String getRodNumber() {
		return RodNumber;
	}

	public void setRodNumber(String rodNumber) {
		RodNumber = rodNumber;
	}

	public String getLongitude() {
		return longitude;
	}

	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}

	public String getLatitude() {
		return latitude;
	}

	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}

	public String getInspection() {
		return Inspection;
	}

	public void setInspection(String inspection) {
		Inspection = inspection;
	}

	public String getError() {
		return error;
	}

	public void setError(String error) {
		this.error = error;
	}

	public String getErrorReason() {
		return errorReason;
	}

	public void setErrorReason(String errorReason) {
		this.errorReason = errorReason;
	}

	public String getErrorFixState() {
		return errorFixState;
	}

	public void setErrorFixState(String errorFixState) {
		this.errorFixState = errorFixState;
	}

	public String getInspectionTime() {
		return InspectionTime;
	}

	public void setInspectionTime(String inspectionTime) {
		InspectionTime = inspectionTime;
	}

	public String getMemo() {
		return Memo;
	}

	public void setMemo(String memo) {
		Memo = memo;
	}

	public String getLocationCode() {
		return locationCode;
	}

	public void setLocationCode(String locationCode) {
		this.locationCode = locationCode;
	}

	@Override
	public String toString() {
		return "ExcelDataBean{" +
				"Epc='" + Epc + '\'' +
				", locationCode='" + locationCode + '\'' +
				", installLocation='" + installLocation + '\'' +
				", IpAddress='" + IpAddress + '\'' +
				", GBID='" + GBID + '\'' +
				", cameraName='" + cameraName + '\'' +
				", RodNumber='" + RodNumber + '\'' +
				", longitude='" + longitude + '\'' +
				", latitude='" + latitude + '\'' +
				", Inspection='" + Inspection + '\'' +
				", error='" + error + '\'' +
				", errorReason='" + errorReason + '\'' +
				", errorFixState='" + errorFixState + '\'' +
				", InspectionTime='" + InspectionTime + '\'' +
				", Memo='" + Memo + '\'' +
				'}';
	}
}
